home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.817 < prev    next >
Text File  |  1992-02-06  |  2KB  |  58 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fswiss Helvetica;}
  2. \paperw11860
  3. \paperh8940
  4. \margl120
  5. \margr1000
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\b0\i0\ul0\fs28\fc0 InterfaceBuilder custom object initialization
  8. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  9. \
  10. Q: I  haven't found a good way to initialize custom objects instantiated by 
  11. \fc0 InterfaceBuilder.   I can incrementally initialize them by defining
  12. \b   set<outlet>:
  13. \b0  methods, but this introduces the possibility of  dependencies on the order in which the outlets are connected. How can custom InterfaceBuilder objects be reliably initialized? \
  14. \
  15. A:  InterfaceBuilder does not send a notification such as 
  16. \b awake:
  17. \b0  after the unarchiving process is complete.  However, you can write your own 
  18. \b awake
  19. \b0  method right after loading in the 
  20. \b .nib
  21. \b0  files.  In this 
  22. \b awake:
  23. \b0  method, you would put all your additional initializing code. See the following code snippet:\
  24.  
  25. \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f1\fs24\fc0 \
  26.  
  27. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 /* You can place your awake method anywhere right after your loadNibxxx message\
  28.  * In this example, FormWindow.nib is a separate nib file, which is loaded\
  29.  * evertime the user wants a new form. \
  30.  */\
  31. - init\
  32. \{\
  33.     [super init];\
  34.     [NXApp loadNibSection:"FormWindow.nib" owner:self withNames:NO];\
  35.     [self myAwake];
  36. \b \
  37.  
  38. \b0     return self;\
  39. \}\
  40. \
  41. - myAwake\
  42. \{\
  43.     /* Do  your additional initialization here\
  44.      * For example, initializing the Form title and string\
  45.      */\
  46.     [theForm setTitle:"Company Name" at:0];\
  47.     [theForm setStringValue:"NeXT Computer Inc." at:0];\
  48.     return self;\
  49. \}\
  50.  
  51. \f0\fs28 \
  52. QA817\
  53. \
  54. Not tested for 1.0\
  55. Valid for 2.0\
  56. \
  57.  
  58.